/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * payInteresForm.java
 *
 * Created on Oct 20, 2011, 10:21:14 PM
 */
package project;

import Utils.Helper;
import Utils.JDBCHelper;
import Utils.checkValidate;
import beanControl.PayInterestcontrol;
import beanInfo.interest;
import beanInfo.payInteres;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

/**
 *
 * @author lyan
 */
public class payInteresForm extends javax.swing.JFrame {

    payInteres pay=new payInteres();
    PayInterestcontrol payct=new PayInterestcontrol();
    SelectProftle selectPro;
    String id="";
    
    /** Creates new form payInteresForm */
    public payInteresForm(String ID) {
        initComponents();
        
    }
  
    
    public void insertPayInteres()
    {
        pay.setPaymentDate(Helper.ConvertDateToString(new java.util.Date()));
        pay.setProfile(Integer.parseInt(txtprofile.getText()));
       
        pay.setBalanceInterest(txtbalan.getText());
        pay.setMoney(txtMoney.getText());
        pay.setStatus("False");
        payct.insertPayInteres(pay);
        txtMoney.setText("");
        txtTotal.setText("");
        txtbalan.setText("");
        txtprofile.setText("");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        lblID = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtbalan = new javax.swing.JTextField();
        txtMoney = new javax.swing.JTextField();
        btnSave = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        txtprofile = new javax.swing.JTextField();
        btnSelect = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        txtTotal = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(0, 102, 102));
        jPanel1.setLayout(null);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setLayout(null);
        jPanel2.add(lblID);
        lblID.setBounds(10, 10, 30, 20);

        jLabel2.setText("ProfileID");
        jPanel2.add(jLabel2);
        jLabel2.setBounds(10, 60, 80, 30);

        jLabel3.setText("BalanceInterest");
        jPanel2.add(jLabel3);
        jLabel3.setBounds(10, 140, 80, 40);

        jLabel4.setText("Money");
        jPanel2.add(jLabel4);
        jLabel4.setBounds(10, 180, 50, 30);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 24));
        jLabel5.setForeground(new java.awt.Color(255, 0, 0));
        jLabel5.setText("Insert PayInterest");
        jPanel2.add(jLabel5);
        jLabel5.setBounds(80, 14, 240, 30);
        jPanel2.add(txtbalan);
        txtbalan.setBounds(100, 140, 180, 30);
        jPanel2.add(txtMoney);
        txtMoney.setBounds(100, 180, 180, 30);

        btnSave.setBackground(new java.awt.Color(0, 102, 102));
        btnSave.setForeground(new java.awt.Color(255, 255, 255));
        btnSave.setText("Save");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });
        jPanel2.add(btnSave);
        btnSave.setBounds(100, 250, 57, 30);

        jButton2.setBackground(new java.awt.Color(0, 102, 102));
        jButton2.setForeground(new java.awt.Color(255, 255, 255));
        jButton2.setText("Cancel");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton2);
        jButton2.setBounds(170, 250, 80, 30);

        txtprofile.setEnabled(false);
        jPanel2.add(txtprofile);
        txtprofile.setBounds(100, 60, 180, 30);

        btnSelect.setText("Select");
        btnSelect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSelectActionPerformed(evt);
            }
        });
        jPanel2.add(btnSelect);
        btnSelect.setBounds(290, 60, 80, 23);

        jLabel6.setText("TotalAmount");
        jPanel2.add(jLabel6);
        jLabel6.setBounds(10, 110, 70, 20);

        txtTotal.setEnabled(false);
        jPanel2.add(txtTotal);
        txtTotal.setBounds(100, 100, 180, 30);

        jPanel1.add(jPanel2);
        jPanel2.setBounds(10, 10, 410, 310);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 332, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
// TODO add your handling code here:
    if(txtbalan.getText().length()==0)
    {Helper.successMessage("Enter BalanceInteres", "wanning");
    }
    else if(txtMoney.getText().length()==0)
    {
        Helper.successMessage("Enter money", "wanning");
    }
    else if(checkValidate.checkFloatNumber(txtbalan.getText())==false)
    {
        Helper.successMessage("balanceInteres is number","wanning");
    }
    else if(checkValidate.checkFloatNumber(txtMoney.getText())==false)
    {
        Helper.successMessage("Money is number","wanning");
    }
    else
    {
        insertPayInteres();
    }
    
}//GEN-LAST:event_btnSaveActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
    this.dispose();
}//GEN-LAST:event_jButton2ActionPerformed

private void btnSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelectActionPerformed
// TODO add your handling code here:
    selectPro = new SelectProftle(null, true, txtprofile, txtTotal);
    selectPro.setVisible(true);
}//GEN-LAST:event_btnSelectActionPerformed

    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(payInteresForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(payInteresForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(payInteresForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(payInteresForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /* Create and display the form */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                new payInteresForm().setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnSave;
    private javax.swing.JButton btnSelect;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JLabel lblID;
    private javax.swing.JTextField txtMoney;
    private javax.swing.JTextField txtTotal;
    private javax.swing.JTextField txtbalan;
    private javax.swing.JTextField txtprofile;
    // End of variables declaration//GEN-END:variables
}
